#include "student.h"
#include "ui_student.h"

#include <QSqlQuery>
#include<QMessageBox>
#include<QSqlQueryModel>

Student::Student(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Student)
{
    ui->setupUi(this);
}

Student::~Student()
{
    delete ui;
}
void Student::selectBoxSlot(QString S)//查询箱子状态
{
    bool ok = connectsqliteS.ok;
    if(ok)
    {
        QSqlQueryModel *model = new QSqlQueryModel(ui->tableView_S);

        model->setQuery(QString("select * from StudentInfoTable where ID = '%1';").arg(S));
        //列名
        model->setHeaderData(0, Qt::Horizontal, tr("ID"));
        model->setHeaderData(1, Qt::Horizontal, tr("xuehao"));
        model->setHeaderData(2, Qt::Horizontal, tr("Name"));
        model->setHeaderData(3, Qt::Horizontal, tr("Sex"));
        model->setHeaderData(4, Qt::Horizontal, tr("Classid"));
        model->setHeaderData(5, Qt::Horizontal, tr("loginpw"));
        model->setHeaderData(7, Qt::Horizontal, tr("RxTime"));
        model->setHeaderData(6, Qt::Horizontal, tr("face"));

        ui->tableView_S->setModel(model);//数据放置进去
        ui->tableView_S->verticalHeader()->hide();//不显示序号
    }
    else
    {
        QMessageBox::warning(this,"错误","未连接，请检查.");
    }
    S1 = S;
}

void Student::slotforms()
{
    formsW->show();
    formsW->str = S1;
}
void Student::slotformskaoqin()
{
    formSkaoqinW->show();
    formSkaoqinW->str = S1;
}
void Student::slotchangesinfo()
{
    changeSinfoW->show();
    changeSinfoW->str = S1;
}

void Student::slotformsmode()
{
    formSModeW->show();
    formSModeW->str = S1;
}

void Student::on_pb_sforget_clicked()
{
    formsW = new FormS;
    connect(formsW,&FormS::signalformS,this,&Student::slotforms);
    this->hide();
    formsW->showformS();
}

void Student::on_pb_modify_clicked()
{
    changeSinfoW = new changeSinfo;
    connect(changeSinfoW,&changeSinfo::signalchangeSinfo,this,&Student::slotchangesinfo);
    this->hide();
    changeSinfoW->showchangeSinfo();
}

void Student::on_pb_mode_clicked()
{
    formSModeW = new FormSMode;
    connect(formSModeW,&FormSMode::signalformSmode,this,&Student::slotformsmode);
    this->hide();
    formSModeW->showformSmode();
}

void Student::on_pb_skaoqin_clicked()
{
    formSkaoqinW = new FormSkaoqin;
    connect(formSkaoqinW,&FormSkaoqin::signalformSkaoqin,this,&Student::slotformskaoqin);
    this->hide();
    formSkaoqinW->showFormSkaoqin();
}

void Student::on_ppb_holiday_clicked()
{
    pronew.startDetached("D:\\openmv\\bin\\openmvide.exe",QStringList());
        if(pronew.isOpen() == true)
        {
          if(pronew.waitForFinished(300000) )
          {
              pronew.close();
          }
        }else{
              pronew.close();
        }
}
